<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /*
        1. 同一个构造函数构建对象其对象原型是相等的，指向构造函数的原型
        2. 可以利用上述特性给所有对象添加统一的属性或方法（共享）
      */
      function Person() {
        // this = {}
        this.age = 20;
        this.uname = "lili";
        // this.__proto__ = Person.prototype;
        // return this;
      }
      Person.prototype.add = function () {
        console.log("add");
      };
      const p1 = new Person();
      const p2 = new Person();
      const p3 = new Person();
      p1.add();
      p2.add();
      p3.add();
      console.log(p1.__proto__ === p2.__proto__);
      console.log(p2.__proto__ === p3.__proto__);
      console.log(p1.__proto__ === p2.__proto__);
    </script>
  </body>
</html>
